<?

require_once ("application.list.inc");

global $_GLOBAL_DBH;
global $_OBJECT_IFACE_PANEL;
global $_IFACE_CONTROL_OBJECT;
global $_SET_TABBING;

$fs_local_document = $_SERVER["PHP_SELF"];

$indexes = array (
	name=>array (label=>"Name",order=>"DEFAULT",alias=>"inv_ctl_products.name"),
	category=>array (label=>"Category",order=>"DEFAULT"),
	description=>array (label=>"Description",order=>"DEFAULT",
			callback=>"_template_list_substring",length=>16),
	unit_price=>array (label=>"Unit Price",order=>"DEFAULT"),
	available=>array (label=>"Date Available",order=>"DEFAULT",wrapper=>"vmc_icon_date"),
);

$link_options_path = array (
        array (
                fs_tab=>"inv_ctl_products",
                fs_tab_option=>"lc_inv_ctl_products",
        )
);

$link_options = _app_create_tabbing (null, $link_options_path);

$object_ctl_path = array (
        array (
                fs_action=>"view",
                fs_tab=>"inv_ctl_products",
                fs_tab_option=>"fs_inv_ctl_products"
        )
);

$object_ctl = _app_create_tabbing ( "{$fs_local_document}?",
                $object_ctl_path) . "&";

$list_options_path = array (
        array (
                fs_tab=>"inv_ctl_products",
                fs_action=>"addnew",
                fs_tab_option=>"fs_inv_ctl_products"
        )
);

$list_options = array (
        array (
                label=>"Add An Item",
                link=>_app_create_tabbing ("{$fs_local_document}?",$list_options_path)
        ),
);

$_OBJECT_IFACE_LIST = _app_create_list_object (array (
                db_conn=>$_GLOBAL_DBH,
                indexes=>$indexes,
		list_count=>"SELECT COUNT(*) FROM inv_ctl_products, inv_ctl_items WHERE item_id=inv_ctl_items.id",
		list_select=>"SELECT inv_ctl_products.id, inv_ctl_items.name, inv_ctl_items.description, inv_ctl_categories.name AS category,inv_ctl_products.unit_price,inv_ctl_products.available FROM inv_ctl_products, inv_ctl_items, inv_ctl_categories WHERE item_id=inv_ctl_items.id AND inv_ctl_products.category_id=inv_ctl_categories.id",
                list_id=>"lc_inv_ctl_products",
                list_options=>$list_options,
                primary_key=>"id",
                primary_relation=>"product_id",
                link_options=>$link_options,
                object_ctl=>$object_ctl
));


if (($_REQUEST["fs_tab"] == "inv_ctl_products") &&
		($_REQUEST["fs_tab_option"] == "fs_inv_ctl_products") &&
		($_REQUEST["product_id"] > 0))
	$_SET_TABBING = true;

array_push ($_IFACE_CONTROL_OBJECT, $_OBJECT_IFACE_LIST);

?>
